package demo;

import java.util.Vector;

//线程安全但不一定安全
public class Demo1 {
    public static void main(String[] args) throws InterruptedException {
        Vector<String> v = new Vector<>();
        Thread t1 = new Thread(() -> {
            if (v.isEmpty() == true) {
                v.add("hello t1");
            }
        });

        Thread t2 = new Thread(() -> {
            if (v.isEmpty() == true) {
                v.add("hello t2");
            }
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(v);
    }
}
